<template>
  <div>
    <bread-crumb name1="权限管理" name2="权限列表"></bread-crumb>
    <el-card>
      <el-table
        border
        stripe
        class="el-table"
        :data="rightList"
        style="width: 100%; margin-top: 10px"
      >
        <el-table-column type="index" label="#"> </el-table-column>
        <el-table-column prop="authName" label="权限说明"> </el-table-column>
        <el-table-column prop="path" label="路径"> </el-table-column>
        <!-- 
          level 0 默认
                1 绿色
                2 红色

         -->
        <el-table-column label="等级">
          <template slot-scope="scoped">
            <div>
              <!-- <p>{{ scoped.row }}</p> -->
              <el-tag v-if="scoped.row.level == 0">一级</el-tag>
              <el-tag type="success" v-else-if="scoped.row.level == 1"
                >二级</el-tag
              >
              <el-tag type="danger" v-else-if="scoped.row.level == 2"
                >三级</el-tag
              >
            </div>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
import BreadCrumb from "@/components/common/breadcrumb/BreadCrumb";
import { rights_list_req } from "@/api/rights.js";
export default {
  mounted() {
    this.getRightList();
  },
  data() {
    return {
      rightList: [],
    };
  },
  components: {
    BreadCrumb,
  },
  methods: {
    async getRightList() {
      const result = await rights_list_req({
        method: "get",
        url: "rights/list",
      });
      console.log(result);
      if (result.meta.status !== 200) {
        return this.$message.error("获取权限列表失败");
      }
      this.rightList = result.data;
    },
  },
};
</script>

<style lang="scss" scoped>
.el-table {
  height: 300px;
  overflow-y: scroll;
}
</style>